﻿@page
@model FangChanCrm.Views.GangWei.GangWeiAddModel
@{
}
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"><</script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<form id="form1" runat="server">
    <div class="page-container" id="admui-pageContent">
        <div class="page animation-fade page-forms">
            <div class="page-header">
                <h1 class="page-title" id="biao1">添加岗位</h1>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                        <a class="icon wb-home" href="javascript:;">岗位管理</a>
                    </li>
                    <li class="breadcrumb-item active" id="biao2">添加岗位</li>
                </ol>
                <label style="display:none" id="lbl_Id"></label>
            </div>
            <div class="page-content">
                <div class="panel">
                    <div class="panel-body container-fluid">
                        <h4 class="example-title"></h4>
                        <div class="row">
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">岗位名称</label>
                                <input type="text" class="form-control" id="ipt_GangWeiMingCheng" name="" placeholder="岗位名称" autocomplete="off" />
                            </div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">所属部门</label>
                                <select class="form-control" id="slt_SuoSuBuMen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                            </div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">岗位类型</label>
                                <input type="text" class="form-control" id="ipt_GangWeilLeiXing" name="" placeholder="岗位类型" autocomplete="off" />
                            </div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">岗位等级</label>
                                <input type="text" class="form-control" id="ipt_GangWeiDengJi" name="" placeholder="岗位等级" autocomplete="off" />
                            </div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-6 row" style="padding-left:70px">
                                <div class="form-group col-sm-1"></div>
                                <div class="form-group col-sm-4" style="padding-top: 70px;">
                                    <button type="button" id="anniu1" class="btn btn-block btn-success" style="width: 100%; margin-left: 15px; float: left;" onclick="TianJiaBuMen()">+添加岗位</button>
                                </div>


                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</form>
<script type="text/javascript" language="javascript" class="init">
    $(document).ready(function () {
        $("#SpanGongSi").click();
        BangDingBuMen();
    });
    function TianJiaBuMen() {
        var ipt_GangWeiMingCheng = $("#ipt_GangWeiMingCheng").val();
        var slt_SuoSuBuMen = $("#slt_SuoSuBuMen").val();
        var ipt_GangWeilLeiXing = $("#ipt_GangWeilLeiXing").val();
        var ipt_GangWeiDengJi = $("#ipt_GangWeiDengJi").val();
        var zhengzhengshu = /^[0-9]\d*$/;
        if (ipt_GangWeiMingCheng == "") {
            alert("部门名称不能为空");
        }
        else if (slt_SuoSuBuMen == 0) {
            alert("所属部门不能为空");
        }
        else if (ipt_GangWeilLeiXing == "") {
            alert("岗位类型不能为空");
        }
        else if (ipt_GangWeiDengJi == "") {
            alert("岗位等级不能为空");
        } else if (!zhengzhengshu.test($("#ipt_GangWeiDengJi").val())) {
            alert("岗位等级只能为正整数");
        } else {
            $.ajax({
                url: "../GangWei/TianJiaGangWei",
                data: { ipt_GangWeiMingCheng: ipt_GangWeiMingCheng, slt_SuoSuBuMen: slt_SuoSuBuMen, ipt_GangWeilLeiXing: ipt_GangWeilLeiXing, ipt_GangWeiDengJi: ipt_GangWeiDengJi },
                type: "post",
                dataType: "text",
                success: function (response) {
                    if (response == "success") {
                        alert('提交成功');
                    } if (response == "error") {
                        alert('提交失败');
                    }
                }
            });
        }
    }

    function BangDingBuMen() {
        $.ajax({
            type: 'POST',
            url: '../GangWei/BangDingBuMen',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#slt_SuoSuBuMen");
                ddl.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].BuMenMingCheng).val(date[key].Id);
                    ddl.append(opt);
                })
            },
        })
    }

</script>